package com.jl.jlsdkdemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.foreign.jlsdk.FxService;
import com.foreign.jlsdk.JLAccountInfo;
import com.foreign.jlsdk.JLAppInfo;
import com.foreign.jlsdk.SDKManager;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initSDK();
        Button button2 = (Button) findViewById(R.id.button2);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                SDKManager.getInstance();
                SDKManager.Login(MainActivity.this, "1", new SDKManager.OnLoginProcessListener() {
                    @Override
                    public void finishLoginProcess(int code, JLAccountInfo arg1) {
                        Toast.makeText(MainActivity.this, "UID:"+arg1.getUid(), Toast.LENGTH_LONG).show();
                        System.out.println("code" + code);
                        System.out.println("getUid" + arg1.getUid());

                    }


                });


            }
        });

    }


    //初始化
    void initSDK() {
        JLAppInfo appInfo = new JLAppInfo();
        // AppID
        // AppKey
        appInfo.setAppId("08afc1ee45874935a78ee6c4bc2074a1");
        appInfo.setAppKey("3bc5fccb140247eab83cee443390e8a8");
        SDKManager.getInstance().Init(this, appInfo);
    }


    @Override
    protected void onRestart() {
        super.onRestart();
        //获得焦点显示悬浮窗
        if (FxService.fse != null) {
            FxService.mFloatView(true);
        }
    }


    @Override
    protected void onPause() {
        super.onPause();
        //失去焦点隐藏悬浮窗
        if (FxService.fse != null) {
            FxService.mFloatView(false);
        }
    }


}
